package com.idp.web.test.service.impl;
import com.idp.web.test.service.StockService;
import com.idp.web.test.dao.StockDao;
import com.idp.web.test.entity.Stock;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.alibaba.druid.util.MapComparator;
import com.idp.common.persistence.Page;
import com.idp.common.util.ResourceUtils;

/**
 * 
 * 123123service实现类
 * 
 * <pre>
 * 	历史记录：
 * 	2017-06-02 Amber
 * 	新建文件
 * </pre>
 * 
 * @author 
 * <pre>
 * SD
 * 	Amber
 * PG
 *	Amber
 * UT
 *
 * MA
 * </pre>
 * @version $Rev$
 *
 * <p/> $Id$
 *
 */
@Service("stockService")
public class StockServiceImpl implements StockService {

	@Resource
	private StockDao stockDao;
	
	@Override
	public Page<Stock> findByPage(Stock stock, Page<Stock> page) {
		page.setResult(stockDao.find(stock, page));
		return page;
	}
	
	@Override
	public List<Stock> findBySearch(Stock stock) {

		return stockDao.find(stock);
	}
	
	@Override
	public Stock getById(Integer id) {

		return stockDao.getById(id);
	}

	@Override
	public Stock getByProductAndWarehouse(Integer productId, Integer warehouseId) {
		Map<String, Integer> map = new HashMap<>();
		map.put("productId", productId);
		map.put("warehouseId", warehouseId);
		return stockDao.getByProductAndWarehouse(map);
	}
	
	@Override
	public Page<Stock> sreachByWarehouseAndProductName(Stock stock, Page<Stock> page) {
		page.setResult(stockDao.sreachByWarehouseAndProductName(stock,page));
		return page;
	}
	
	@Override
	public void add(Stock stock) {

		stockDao.add(stock);
	}
	
	@Override
	public void update(Stock stock) {

		stockDao.update(stock);
	}

	@Override
	public void delete(Integer id) {

		stockDao.delete(id);
	}
 	
}